<extend name="Public:base" />
<block name="main">
	<div class="content">
		<section class="location">
			<i class="iconfont">&#xe60f</i> 位置：<a href="{:U('Index/main')}">管理首页</a> &gt; <a href="{:U('index')}">管理员设置</a> &gt; 新增管理员
		</section>
		<ul class="nav-tabs clearfix">
			<li><a href="{:U('password')}">修改密码</a></li>
			<li><a href="{:U('index')}">管理员列表</a></li>
			<li class="active">新增管理员</li>
		</ul>
		<form method="post" action="" id="form">
			<input type="hidden" name="class" id="class" value="{$Think.CONTROLLER_NAME}" />
			<table width="100%" border="0" cellspacing="0" cellpadding="0" class="table">
			<tr>
				<th width="100">登录ID</th>
				<td><input type="text" name="username" id="username" class="form-control form-control-sm" required /> <span class="red"> *</span>4-20位英文或字母组合</td>
			</tr>
			<tr>
				<th>密码</th>
				<td><input type="password" name="password" id="password" class="form-control form-control-sm" required /> <span class="red"> *</span>密码长度6-30</td>
			</tr>
			<tr>
				<th>确认密码</th>
				<td><input type="password" name="repassword" id="repassword" class="form-control form-control-sm" required /> <span class="red"> *</span> </td>
			</tr>
			<tr>
				<th>笔名</th>
				<td><input type="text" name="author" id="author" class="form-control form-control-sm" /></td>
			</tr>
			<tr>
				<th>用户类型</th>
				<td>
					<select name="usertype" id="usertype" class="form-control">
						<option value="3">频道管理员</option>
						<option value="2">管理员</option>
					</select>
				</td>
			</tr>
			<tr>
				<th>负责栏目</th>
				<td>
					<select name="typeids[]" id="typeids" size="10" multiple="true">
						<option value="0">——所有栏目——</option>
						<foreach name="category" item="list">
						<option value="{$list.id}" <if condition="$list.id eq $viewInfo['category_id']">selected</if>>{$list.delimiter}<if condition="$list.parent_id neq 0">├─</if>{$list.name}</option>
						</foreach>
					</select>
				</td>
			</tr>
			<tr>
				<th>真实姓名</th>
				<td><input type="text" name="name" id="name" class="form-control form-control-sm" /></td>
			</tr>
			<tr>
				<th>联系电话</th>
				<td><input type="text" name="phone" id="phone" class="form-control form-control-sm" /></td>
			</tr>
			<tr>
				<th>电子邮箱</th>
				<td><input type="text" name="email" id="email" class="form-control form-control-sm" /></td>
			</tr>
			</table>
			<div class="well"><button type="submit" class="btn btn-theme" id="submit_admin">新 增</button> <button class="btn btn-gary" onclick="javascript:history.back(-1);">返 回</button></div>
		</form>
	</div>
</block>
<block name="JS">
<script>
	$('#submit_admin').click(function(){
		event.preventDefault();
		var Url = "{:U('add')}";
		$.ajax({
			type: 'post',
			url: Url,
			data: $("#form").serialize(),
			success: function(data) {
				if(data.status==1){
					swal({
						title: data.msg,
						text: "",
						type: 'success',
						showCancelButton: false,
						confirmButtonText: '确定'
					}).then(function() {
						location.href = data.callback;
					});
				}else{
					swal(data.msg,'','error');
				}
			}
		});
	});
</script>
</block>
